{include file="Public:header2"/}
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <form method="get" team="{:url('/admin/product')}" class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">搜索商品</label>
                    <div class="layui-input-block">
                        <input type="text" name="keyword" value="{$Request.get.keyword}" placeholder="请输入商品名称" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">分类</label>
                    <div class="layui-input-inline cate1">
                        <select name="cate_id" lay-verify="" lay-filter="choose">
                            <option  value="0">--请选择分类--</option>
                            {foreach name="cate" item="vo"}
                                <option {if condition="$Request.get.cate_id eq $vo['id']"}selected{/if} value="{$vo.id}">{$vo.title}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-block">
                        <select name="status" style="width:100%">
                            <option value="">--请选择状态--</option>
                            <option value="1" {if condition="$Request.get.status eq 1"}selected{/if}>正常</option>
                            <option value="2" {if condition="$Request.get.status eq 2"}selected{/if}>下架</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="LAY-user-front-search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </div>
        </form>

        <div class="layui-card-body">
            <xblock>
                <div style="padding-bottom: 10px;">
                    <a class="layui-btn" href="javascript:;" onclick="tan_tiao('添加商品','{:url('/admin/product_add')}')">添加商品</a>
                    <span style="line-height:40px;float:right;">共有数据： {$count}条</span>
                </div>
            </xblock>
            <table class="layui-table" style="text-align:center">
                <thead>
                <tr>
                    <th>商品名称</th>
                    <th>商品图片</th>
                    <th>商品分类</th>
                    <th>商品价格</th>
                    <th>状态</th>
                    <th>排序值</th>
                    <th>时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                    {volist name="list" id="vo"}
                        <tr>
                            <td>{$vo['title']}</td>
                            <td><img src="{PHP} echo imageUrl($vo['imgurl']){/php}" style="width:60px;height:60px;"></td>
                            <td>{$vo['cate_title']}</td>
                            <td>{$vo['price']}</td>
                            <td>
                                {if condition="$vo['status'] eq 1"}
                                    <button class="layui-btn layui-btn-normal layui-btn-radius layui-btn-sm">正常</button>
                                {elseif condition="$vo['status'] eq 2" /}
                                    <button class="layui-btn layui-btn-warm layui-btn-radius layui-btn-sm">下架</button>
                                {/if}
                            </td>
                            <td>{$vo['sort']}</td>
                            <td>{$vo['addtime']|date="Y-m-d H:i:s"}</td>
                            <td>
                                <a style="text-decoration:none" title="编辑" href="javascript:;" onclick="tan_tiao('编辑商品','{:url('/admin/product_edit',['id'=>$vo['id']])}')" class="layui-btn layui-btn-radius layui-btn-default layui-btn-xs">编辑</a>
                                <a style="text-decoration:none" title="删除" onClick="del({$vo.id},'3')" class="layui-btn layui-btn-danger layui-btn-radius layui-btn-xs">删除</a>
                                
                            </td>
                        </tr>
                    {/volist}
                
                        {if condition="empty($list)"}
                            <tr><td colspan='10' style="text-align:center;">暂时没有数据！</td></tr>
                        {/if}
                </tbody>
            </table>
            <div class="layui-box layui-laypage layui-laypage-default" style="margin-left:40%">
                {$page|raw}
            </div>
        </div>
    </div>
</div>
{include file="Public:footer"/}
<script type="text/javascript">
    layui.use(['table','form'], function(){
        var $ = layui.$;
        var form = layui.form;
    });
    

    //删除
    function del(id,stu){
        layer.confirm('确认要执行当前操作吗？',function(){
            var url = "{:url('/admin/product_del')}";
            var load=layer.load(2);
            var $ = layui.$;
            $.post(url,{"id":id,'stu':stu},function(data){
                if(data.status == 1){
                    layer.msg(data.msg,{icon:1,time:1000},function(){
                        location.reload();
                    });
                }else{
                    layer.msg(data.msg,{icon:2,anim:6,time:1500},function(){
                        layer.close(load);
                    });
                }
            })
        });
    }



</script>
</body>
</html>


